package com.shou.zhnfyxt.utils;

import com.shou.zhnfyxt.entity.R;
import io.jsonwebtoken.ExpiredJwtException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(ExpiredJwtException.class)
    public R<String> globalException(HttpServletResponse response, RuntimeException e){
        log.info("GlobalExceptionHandler...");
        log.info("错误代码："  + response.getStatus());
        return R.error(666);
    }
}
